#!/bin/csh -f
if(! -f mktm.def) then
    echo "File mktm.def must be present in the curdir"
    exit
endif
set rn=`awk '$1=="rootname"{print $2}' mktm.def`
set ti=`awk '$1=="tilings"{print $2}' mktm.def`
set erep=`awk '$1=="erep"{print $2}' mktm.def`
set mdir=`pwd`
set tind=`awk '{print $1}' $rn.ldef`
@ j =0
echo exporting $#tind monolayer tilings to ttmps
foreach i ($tind)
    @ j++
    cat $ti | poptil $i > ttmp
    if($j == 1) then
	head -3 ttmp |awk 'BEGIN{nt=ARGV[1];ARGV[1]="-"}FNR==3{nn=$1;mu=$2}FNR<3{b=b$0"\n"}END{print nn,mu,nt"  # mgroup";printf b}' $#tind > ttmps
    endif
    cat ttmp | awk 'FNR>3'>> ttmps
end

##
